let Form = function (options) {
	let self = $.extend(this, options);
	self.form = $(self.element);
	self.init = function (view) {
		if (typeof FormValidation === 'undefined') {
			fcUtil.loadScript('/static/plugins/formvalidation/formValidation.js', function () {
				fcUtil.loadScript('/static/plugins/formvalidation/framework/bootstrap.js', function () {
					self.init();
				});
			});
			return false;
		}
		self.validation = new Validation();
		self.formValidation = $(self.element).formValidation($.po('formValidation', {
			button: {
				//selector: self.element,
				disabled: 'disabled'
			},
			fields: self.validation.init.apply(self) //self.fields //
		}));
		$(self.element).submit(function (e) {
			e.preventDefault();
		});
		$(self.element).unbind('success.form.fv').bind('success.form.fv', function (e) {
			let data = $(e.target).serializeObject();
			//处理数组  以后优化
			for (let key in data) {
				if (key.indexOf('[]') > -1) {
					data[key.replace('[]', '')] = (data[key] instanceof Array) ? data[key] : [data[key]]
				}
			}
			//----------
			let url = self.url || view[self.type + '_url'];
			if (self.before_callback) {
				data = self.before_callback(data);
				if (data === false) {
					return false;
				}
			}
			if (self.loading) {
				$('#rotateCircle').css('display', 'block');
			}
			wdAjax({
				url: url,
				data: data,
				success: function (data) {
					if (self.success) {
						self.success(data);
						if (self.loading) {
							$('#rotateCircle').css('display', 'none');
						}
					}
				},
				error: function () {
					let fv = $(self.element).data('formValidation');
					fv.resetForm();
					if (self.error_callback) {
						self.error_callback(data);
					}
					if (self.loading) {
						$('#rotateCircle').css('display', 'none');
					}
				}
			})
			return false;
		});
	};
	return self;
};